package com.jinmdz.fmis.api.api.controller;

import com.jinmdz.fmis.api.api.model.funeral.BusinessCodeData;
import com.jinmdz.fmis.api.api.model.funeral.CremationArchivesData;
import com.jinmdz.fmis.api.api.model.funeral.CremationArchivesItem;
import com.jinmdz.fmis.api.api.model.funeral.CremationPrintInfo;
import com.jinmdz.fmis.api.api.service.CremationArchivesService;
import com.jinmdz.fmis.api.base.BaseController;
import com.jinmdz.fmis.core.annotation.AnAuthorize;
import com.jinmdz.fmis.core.base.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


/**
 * 火化逝者信息登记相关接口
 *
 * @author LiCongLu
 * @date 2020-01-19 13:28
 */
@Api(description = "火化逝者信息登记相关接口")
@AnAuthorize(menu = ".service.home")
@RestController()
@RequestMapping("/api/cremation-archives")
public class CremationArchivesController extends BaseController {

    @Resource
    private CremationArchivesService cremationArchivesService;

    /**
     * 根据funeral_dead表中businessCode加载火化逝者信息
     *
     * @param data 业务编码数据
     * @return
     * @author LiCongLu
     * @date 2020-01-19 13:33
     */
    @AnAuthorize(menu = ".service.home", buttons = {"btnBusinessCodeScanning"})
    @ApiOperation(value = "根据funeral_dead表中businessCode加载火化逝者信息", notes = "根据businessCode加载火化逝者信息，信息包括：逝者信息、逝者家属信息、承办人信息，信息中承办人信息不一定存在，是根据殡仪馆业务进行配置的。")
    @PostMapping("/load-cremation-archives-with-business-code")
    public BaseResult<CremationArchivesItem> loadCremationArchivesWithBusinessCode(@RequestBody BusinessCodeData data) {
        return resultHandler(data, userItem -> cremationArchivesService.loadCremationArchivesWithBusinessCode(data));
    }

    /**
     * 提交并保存火化逝者信息登记界面上的表单数据
     *
     * @param data 逝者档案数据
     * @return
     * @author LiCongLu
     * @date 2020-01-19 13:46
     */
    @AnAuthorize(menu = ".service.home", buttons = {"btnSaveFuneralBusiness", "btnSaveJumpServiceNegotiation"})
    @ApiOperation(value = "提交并保存火化逝者信息登记界面上的表单数据", notes = "将火化逝者信息登记界面上的表单数据保存到数据库，信息包括：逝者信息、逝者家属信息、承办人信息，信息中承办人信息不一定存在，是根据殡仪馆业务进行配置的。")
    @PostMapping("/save-cremation-archives")
    public BaseResult<CremationArchivesItem> saveCremationArchives(@RequestBody CremationArchivesData data) {
        return resultHandler(data, userItem -> cremationArchivesService.saveCremationArchives(userItem, data));
    }

    /**
     * 根据funeral_dead表中businessCode加载打印逝者二维码
     *
     * @param data 业务编码数据
     * @return
     * @author GaoXiangLiang
     * @date 2020-06-30 10:37
     */
    @ApiOperation(value = "根据funeral_dead表中businessCode加载打印逝者二维码", notes = "根据funeral_dead表中businessCode加载打印逝者二维码")
    @PostMapping("/load-print-cremation-archives-code-with-business-code")
    public BaseResult<CremationArchivesItem> loadPrintCremationArchivesCodeWithBusinessCode(@RequestBody BusinessCodeData data) {
        return resultHandler(data, userItem -> cremationArchivesService.loadPrintCremationArchivesCodeWithBusinessCode(data));
    }
    /**
     * 根据funeral_dead表中businessCode加载打印逝者二维码新接口
     * @param data 业务编码数据
     * @return
     * @author GaoXiangLiang
     * @date 2020-06-30 10:37
     */
    @ApiOperation(value = "根据funeral_dead表中businessCode加载打印逝者二维码", notes = "根据funeral_dead表中businessCode加载打印逝者二维码")
    @PostMapping("/load-print-cremation-archives-with-business-code")
    public BaseResult<CremationPrintInfo> loadPrintCremationArchivesWithBusinessCode(@RequestBody BusinessCodeData data) {
        return resultHandler(data, userItem -> cremationArchivesService.loadPrintCremationArchivesWithBusinessCode(data));
    }
}
